@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "datestamp=%YYYY%%MM%%DD%"
set "timestamp=%HH%%Min%%Sec%"
@set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
set "fullstamp=%YYYY%%MM%%DD%_%HH%%Min%%Sec%"
set "checkcode=%YY%%MM%%DD%%HH%%Min%"

@rem echo datestamp: "%datestamp%"
@rem echo timestamp: "%timestamp%"
echo build time: "%fullstamp%"

if exist xlx_timestamp.h (del ewin_timestamp.h)

echo // create by Kenglee  >> xlx_timestamp.h
echo #ifndef __XLX_TIMESTAMP_H__  >> xlx_timestamp.h
echo #define __XLX_TIMESTAMP_H__  >> xlx_timestamp.h
REM echo. >> xlx_timestamp.hs
echo #define EWDATESTAMP "%datestamp%" >> xlx_timestamp.h
echo #define EWTIMESTAMP "%timestamp%" >> xlx_timestamp.h
echo #define EWFULLSTAMP "%fullstamp%" >> xlx_timestamp.h
echo #define EWCHECKCODE "%checkcode%" >> xlx_timestamp.h
echo. >> xlx_timestamp.h
echo #endif  >> xlx_timestamp.h
echo // create by Kenglee >> xlx_timestamp.h

move xlx_timestamp.h %~dp0\main\xlx_code\inc\